#include <iostream>
#include <vector>
using namespace std;

const int kmod = 1000000007;
int ans = 0;
vector<int> tmp(100005);

void mergSort(vector<int> &nums, int l, int r) {
    if (l >= r) return;
    int mid = l + (r - l) / 2;
    mergSort(nums, l, mid);
    mergSort(nums, mid + 1, r);
    int i = l, j = mid + 1, cur = l;
    while (i <= mid && j <= r) {
        if (nums[i] < nums[j])
            tmp[cur++] = nums[i++];
        else {
            tmp[cur++] = nums[j++];
            ans += (mid - i + 1);
            ans %= kmod;
        }
    }
    if (i == mid + 1) {
        while (j <= r) tmp[cur++] = nums[j++];
    }else{
        while(i <= mid) tmp[cur++] = nums[i++];
    }
    for(int t = l;t<=r;t++) nums[t] = tmp[t];
}

int InversePairs(vector<int> data) {
    mergSort(data, 0, data.size()-1);
    return ans;
}

int main(){
    vector<int> data = {1,2,3,4,5,6,7,0};
    int ans = InversePairs(data);
    cout << ans << endl;
    return 0;
}